package com.lagou.jedis;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

/**
 * @author lixingwei
 * @date 2020/11/21 00:40:32
 */
public class JedisTest {
    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<>();
        jedisClusterNode.add(new HostAndPort("192.168.102.141", 6379));
        jedisClusterNode.add(new HostAndPort("192.168.102.141", 6380));
        jedisClusterNode.add(new HostAndPort("192.168.102.141", 6381));
        jedisClusterNode.add(new HostAndPort("192.168.102.141", 6382));
        jedisClusterNode.add(new HostAndPort("192.168.102.141", 6383));
        jedisClusterNode.add(new HostAndPort("192.168.102.141", 6384));
        jedisClusterNode.add(new HostAndPort("192.168.102.141", 6385));
        jedisClusterNode.add(new HostAndPort("192.168.102.141", 6386));
        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);
        String result = jcd.set("name:002", "carnation");
        System.out.println(result);
        String value = jcd.get("name:001");
        System.out.println(value);
        value = jcd.get("name:002");
        System.out.println(value);
    }
}
